<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib prefix="a4j" uri="http://richfaces.org/a4j"%>
<%@taglib prefix="rich" uri="http://richfaces.org/rich"%>


<f:subview id="step5">

            <a4j:outputPanel id="tabella">
                <h:panelGrid columns="3">

                    <h:outputText value="#{msg.data_yet_done}" />
                    <h:inputText value="#{addExaminations.scadenza}" required="true" id="data" requiredMessage="#{msg.required_text_error}">
                        <f:convertDateTime pattern="dd/MM/yyyy" />
                    </h:inputText>
                    <rich:message for="data"  errorClass="error-message" />

                    <h:outputText value="#{msg.type}" />
                    <h:selectOneMenu value="#{addExaminations.tipo}" required="true" id="tipo">
                        <f:selectItem itemValue="1" itemLabel="#{msg.prog_bd}" />
                        <f:selectItem itemValue="2" itemLabel="#{msg.vaccination}"/>
                    </h:selectOneMenu>
                    <rich:message for="tipo"  errorClass="error-message" />

                    <h:outputText value="#{msg.description}" />
                    <h:inputTextarea value="#{addExaminations.descrizione}" required="true" requiredMessage="#{msg.required_text_error}" id="desc" />
                    <rich:message for="desc"  errorClass="error-message" />

                    <a4j:commandButton action="#{addExaminations.addExamination()}" value="add" reRender="tabella" >
                        <a4j:support event="onclick" reRender="tabella" immediate="true" />
                    </a4j:commandButton>
                </h:panelGrid>

                <rich:extendedDataTable value="#{addExaminations.lista}" var="visita" styleClass="wide" >

                    <rich:column sortBy="#{visita[1]}" label="#{msg.date_hour}" width="130px">
                        <f:facet name="header">
                            <h:outputText value="#{msg.date_hour}"/>
                        </f:facet>
                        <h:outputText value="#{visita[1]}" />
                    </rich:column>

                    <rich:column sortBy="#{visita[0]}" label="#{msg.type}" width="130px" >
                        <f:facet name="header">
                            <h:outputText value="#{msg.type}"/>
                        </f:facet>
                        <h:outputText value="#{msg.prog_exam}" rendered="#{visita[0] == 1}" />
                        <h:outputText value="#{msg.vaccination}" rendered="#{visita[0] == 2}" />
                    </rich:column>

                    <rich:column sortBy="#{visita[2]}" label="#{msg.description}" width="344px">
                        <f:facet name="header">
                            <h:outputText value="#{msg.description}"/>
                        </f:facet>
                        <h:outputText value="#{visita[2]}" />
                    </rich:column>

                    

                </rich:extendedDataTable>



                <a4j:commandButton action="#{addExaminations.saveExaminations()}" value="#{msg.add_examinations}" immediate="true"/>  
            </a4j:outputPanel>
</f:subview >